<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>提交作业</title>
    <link rel="stylesheet" type="text/css" href="../../static/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/css/main.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/layui/css/layui.css"/>
    <link rel="shortcut icon" href="../resources/favicon.ico" th:href="@{/static/favicon.ico}"/>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <style>
        th {
            width: 100px;
            text-align: center;
        }

        td {
            /*width: 100%;*/
            text-align: center;
        }

        #title {
            width: 530px;
        }

        #content {
            width: 530px;
        }

        #date {
            width: 530px;
        }

        .main-wrap {
            margin-left: 0;
        }
    </style>
</head>
<body>

<!--<div class="container clearfix">-->
<!--	<div class="sidebar-wrap">-->
<!--		<div class="sidebar-title">-->
<!--			<h1>菜单</h1>-->
<!--		</div>-->
<!--		<div class="sidebar-content">-->
<!--			<ul class="sidebar-list">-->
<!--				<li>-->
<!--					<ul class="sub-menu">-->
<!--						<li><a href="/publishtask.html"><i class="icon-font">&#xe012;</i>发布作业</a></li>-->
<!--						<li><a href="/not_publish.html"><i class="icon-font">&#xe005;</i>未发布作业</a></li>-->
<!--					</ul>-->
<!--				</li>-->
<!--			</ul>-->
<!--		</div>-->
<!--	</div>-->

<input type="hidden" th:value="${task.getTask_id()}" id="taskId">
<input type="hidden" th:value="${task.getCla_name()}" id="taskClass">
<input type="hidden" th:value="${task.getT_name()}" id="taskTeacher">
<input type="hidden" th:value="${session.student.getS_name()}" id="taskStudent">
<div class="sidebar-content">
    <div class="main-wrap">
        <div class="result-wrap">
            <div class="result-content">
                <form method="post" id="myform" name="myform " action="" class="layui-form">
                    <table class="insert-tab" width="60%">
                        <tbody>
                        <tr>
                            <th>作业标题：</th>
                            <td>
                                <input class="common-text required" id="title" name="" size="50" th:value="${task.getTask_name()}" type="text" readonly>
                            </td>
                        </tr>
                        <tr>
                            <th>作业内容：</th>
                            <td height="80px">
                                <input class="common-text required" id="content" style="height: 60%;width: 99%" name="" size="50"
                                       th:value="${task.getTask_content()}" type="text" readonly>
                            </td>
                        </tr>
                        <tr>
                            <th>作业：</th>
                            <td>
								<textarea class="layui-textarea fly-editor" lay-verify="contents"
                                          type="text" name="contents" id="contents"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <th>作业结束时间：</th>
                            <td>
                                <div class="layui-form">
                                    <div class="layui-inline">
                                        <div class="layui-input-inline">
<!--                                            <input type="text" class="layui-input" id="test5" placeholder="yyyy-MM-dd HH:mm:ss">-->
                                            <input type="text" class="layui-input" id="test5"th:value="${task.getTask_end_time()}" readonly>
                                        </div>
                                    </div>
                                </div>
                                <!--</div>-->
                            </td>
                        </tr>
                        <tr>
                            <th></th>
                            <td style="text-align: center">
                                <input id="submit" class="btn btn-primary btn6 mr10" lay-submit
                                       value="发布" type="submit" lay-filter="formSubmit">
                                <input id="save" class="btn btn btn6 mr10" lay-submit value="暂存"
                                       type="submit" lay-filter="formSave">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
    </div>
</div>
<!--</div>-->
<script src="../static/layui/layui.js" charset="utf-8"></script>
<!--<script>-->
<!--    layui.use('laydate', function () {-->
<!--        var laydate = layui.laydate;-->
<!--        //日期时间选择器-->
<!--        laydate.render({-->
<!--            elem: '#test5'-->
<!--            , type: 'datetime'-->
<!--        });-->


<!--    });-->
<!--</script>-->

<script>
    <!-- 发布 -->
    layui.use(['layedit', 'form'], function () {
        var layedit = layui.layedit;
        var index = layedit.build('contents');
        var form = layui.form;
        form.verify({
            contents: function (value) {
                layedit.sync(index);
            }
        });
        form.on("submit(formSubmit)", function (data) {
            var taskId = $("#taskId").val();
            var taskStudent = $("#taskStudent").val();
            var taskClass = $("#taskClass").val();
            var taskTeacher = $("#taskTeacher").val();
            var contents = $("#contents").val();
            if (taskId == "" || taskStudent == "" || taskClass == "" || taskTeacher == "" || contents == "") {
                alert("请输入!")
                return false;
            }
            $.ajax({
                type: "post",
                url: "/student/submit",
                data: {
                    taskId:taskId,
                    taskClass:taskClass,
                    taskTeacher:taskTeacher,
                    contents: contents,
                    taskStudent:taskStudent
                },
                success: function (data) {
                    if (data == "1") {
                        location.href = "/student/toNotSubmitList"
                    }
                },
                error: function () {
                    alert("ajax error");
                }

            })
            return false;
        })
    });
</script>
<!-- //暂存 -->
<script>
    layui.use(['layedit', 'form'], function () {
        var layedit = layui.layedit;
        var index = layedit.build('contents');
        var form = layui.form;
        form.verify({
            contents: function (value) {
                layedit.sync(index);
            }
        });
        form.on("submit(formSave)", function (data) {
            var title = $("#title").val();
            var contents = $("#contents").val();
            var date = $("#date").val();
            if (title == "" || contents == "" || data == "") {
                alert("请输入!")
                return false;
            }
            $.ajax({
                type: "post",
                url: "",
                data: {
                    title: title,
                    contents: contents,
                    date: date
                },
                success: function (data) {
                    if (data == "1") {
                        window.location.href = ""
                    }
                },
                error: function () {
                    alert("ajax error");
                }

            })
            return false;
        })
    });
</script>
</body>
</html>
